package com.example.Holo.rework.services.implementation;

import com.example.Holo.rework.core.Event;
import com.example.Holo.rework.dao.interfaces.IDaoFactory;
import com.example.Holo.rework.dao.interfaces.IEventDao;
import com.example.Holo.rework.services.interfaces.IEventService;

import java.util.List;

final class EventService extends Service implements IEventService {

    public EventService(IDaoFactory daoFactory) {
        super(daoFactory);
    }

    @Override
    public List<Event> getAllEvents() {
        final IEventDao eventDao = daoFactory.createEventDao();
        return eventDao.getAll();
    }

    @Override
    public long addEvent(Event event) {
        final IEventDao eventDao = daoFactory.createEventDao();
        return eventDao.add(event);
    }

    @Override
    public int removeEvent(Long id) {
        final IEventDao eventDao = daoFactory.createEventDao();
        return eventDao.remove(id);
    }

    @Override
    public Event getEventById(long addedEventId) {
        final IEventDao eventDao = daoFactory.createEventDao();
        return eventDao.getEntityById(addedEventId);
    }

}
